package com.isoft.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.isoft.mapper.ClassifiedFieldsMapper;
import com.isoft.pojo.dto.PageQueryClassifiedFieldsDTO;
import com.isoft.pojo.vo.ClassifiedFieldsVO;
import com.isoft.result.PageResult;
import com.isoft.service.ClassifiedFieldsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassifiedFieldsServiceImpl implements ClassifiedFieldsService {
    @Autowired
    private ClassifiedFieldsMapper classifiedFieldsMapper;

    /**
     * 分页查询数据分级分类列表
     * @param pageQueryClassifiedFieldsDTO
     * @return
     */
    @Override
    public PageResult<ClassifiedFieldsVO> pageClassifiedFields(PageQueryClassifiedFieldsDTO pageQueryClassifiedFieldsDTO) {
        PageHelper.startPage(pageQueryClassifiedFieldsDTO.getPage(),pageQueryClassifiedFieldsDTO.getSize());
        List<ClassifiedFieldsVO> list = classifiedFieldsMapper.pageClassifiedFields(pageQueryClassifiedFieldsDTO);
        Page<ClassifiedFieldsVO> page = (Page<ClassifiedFieldsVO>) list;
        return new PageResult(page.getTotal(),page.getPages(),pageQueryClassifiedFieldsDTO.getPage(),pageQueryClassifiedFieldsDTO.getSize(),page.getResult());
    }
}
